<?php
include("../../inc/psa_conect.php");
if ($_REQUEST["boton"] == "actualiza" and $_REQUEST["id"]== 0){
    $boton = "agrega";
}else{
    $boton = $_REQUEST["boton"];
}
if ($boton == "actualiza"){
   $sql  = "UPDATE clientes SET ";
   $sql .= "idCompany    = '".$_REQUEST["idCompany"]."', ";
   $sql .= "Company      = '".$_REQUEST["Company"]."', ";
   $sql .= "Country      = '".$_REQUEST["Country"]."', ";
   $sql .= "Prefix       = '".$_REQUEST["Prefix"]."', ";
   $sql .= "FirstName    = '".$_REQUEST["FirstName"]."', ";
   $sql .= "LastName     = '".$_REQUEST["LastName"]."', ";
   $sql .= "Email        = '".$_REQUEST["Email"]."', ";
   $sql .= "WorkPhone    = '".$_REQUEST["WorkPhone"]."', ";
   $sql .= "OtherNumber  = '".$_REQUEST["OtherNumber"]."', ";
   $sql .= "WebSite      = '".$_REQUEST["WebSite"]."', ";
   $sql .= "Street       = '".$_REQUEST["Street"]."', ";
   $sql .= "City         = '".$_REQUEST["City"]."', ";
   $sql .= "Zip          = '".$_REQUEST["Zip"]."', ";
   $sql .= "Notes        = '".$_REQUEST["Notes"]."' ";
   $sql .= " WHERE id=".$_REQUEST["id"];
} else {
   if ($boton == "elimina"){
      $sql = "delete from clientes WHERE id=".$_REQUEST["id"];
   } else {
      if ($boton == "agrega"){
         $sql  = "INSERT INTO clientes (id, idCompany, Company, Country, Prefix, FirstName, LastName, Email, WorkPhone, OtherNumber, WebSite, Street, City, Zip, Notes) ";
         $sql .= "VALUES (NULL, '".$_REQUEST["idCompany"]."', '".$_REQUEST["Company"]."', '".$_REQUEST["Country"]."', '".$_REQUEST["Prefix"]."', '".$_REQUEST["FirstName"]."', '".$_REQUEST["LastName"]."', '".$_REQUEST["Email"]."', '".$_REQUEST["WorkPhone"]."', '".$_REQUEST["OtherNumber"]."', '".$_REQUEST["WebSite"]."', '".$_REQUEST["Street"]."', '".$_REQUEST["City"]."', '".$_REQUEST["Zip"]."', '".$_REQUEST["Notes"]."')";
      }
   }
}
$result = mysql_query($sql,$link);
//echo $sql;
header("location: ../../index.php?psa_modulo=".$_REQUEST["psa_modulo"]);
?>